export default {
	// 获取页面数据
	getTableData() {
		var params = {
			category_id:this.type,
			language: this.$store.getters.getLanguage,
			page: this.$refs.Page.pagination.current,
			limit: this.$refs.Page.pagination.pageSize
		}
		this.axiosPost("Development/productList", params, function(res) {
			console.log(res);
			if(res.data.code === 0) {
				this.tableData = res.data.data.data;
				this.total = res.data.data.total
				// this.msgSuccess(res.data.message)
			} else  {
				this.msgError(res.data.message)
			}
			//分页
			// console.log(this.total);
		})
	},
	
	getType(){
		let params = {
			language: this.$store.getters.getLanguage,
			page: 1,
			limit: 100000000
		}
		this.axiosPost("Development/categoryList", params, function(res) {
			// console.log(res);
			if(res.data.code === 0) {
				this.opt = res.data.data.data
			}
		})
	},
	

	add(){
		this.$refs.Edit.opt = this.opt;
		this.$refs.Edit.isShow = true;
	},

	//编辑
	edit(scope) {
		this.$refs.Edit.opt = this.opt;
		this.$refs.Edit.getDetail(scope.id);

		this.$refs.Edit.isShow = true;
	},

	//删除
	remove(scope) {
		this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
			confirmButtonText: '确定',
			cancelButtonText: '取消',
			type: 'warning'
		}).then(() => {

			this.sureRemove(scope.id);
		}).catch(() => {
			this.$message({
				type: 'info',
				message: '已取消删除'
			});
		});
	},

	//确定删除
	sureRemove(id) {

		this.axiosGets("Development/productDel?id=" + id, {}, function(res) {
			if (res.data.code === 0) {
				this.getTableData();
				this.msgSuccess(res.data.message)
			} else {
				this.msgError(res.data.message)
			}
		})
	}
}
